package com.wty.basic.array;

/**
 * 二维数组
 * @Author wangtengyu
 * @Create 2018-08-06-9:09
 */
public class Test2 {
    public static void main(String[] args) {
        //就算指定了列数，实际使用中越界也不会报错
        int a[][]=new int[3][1];
        a[0]=new int[]{1};
        a[1]=new int[]{2,3,2,3,4};
        a[2]=new int[]{4,5};
        for (int x[]:a){
            for (int y:x){
                System.out.print(y+"  ");
            }
            System.out.println();
        }
        System.out.println(a.length);
        System.out.println(a[0].length);
        System.out.println(a[1].length);

        System.out.println("--------------------------------------------------------------");
        int [][]b=new int[][]{{1,2},{1,2,3,4,5},{'a'},{5,4,3,2,1}};
        for (int x[]:b){
            for (int y:x){
                System.out.print(y+"  ");
            }
            System.out.println();
        }
        System.out.println(b.length);
        System.out.println(b[0].length);
        System.out.println(b[1].length);

        System.out.println("--------------------------------------------------------------");
        char [][] chars=new char[][]{{97,99},{'a'}};
        for (char x[]:chars){
            for (char y:x){
                System.out.print(y+"  ");
            }
            System.out.println();
        }
        System.out.println(chars.length);
        System.out.println(chars[0].length);
        System.out.println(chars[1].length);

    }
}
